home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CreatingGames / Utilities / Misc / GMS / GMSDev / Source / C / StartDPK / AsmStartDPK.s < prev    next >
Encoding:
Text File  |  1997-12-09  |  1.7 KB  |  69 lines

  1. ;-------T-------T------------------------T------------------------------------------;
  2.  
  3.     xdef    _LaunchTask
  4.     xdef    _DPKBase
  5.  
  6.     INCDIR    "GMSDev:Includes/"
  7.     INCLUDE    "dpkernel/dpkernel.i"
  8.     INCLUDE    "files/segments.i"
  9.  
  10. ;===================================================================================;
  11. ;                                    LAUNCH CODE
  12. ;===================================================================================;
  13. ;This part had to be written in assembler due to the InitDestruct() code, which
  14. ;requires a correct stack pointer.
  15.  
  16.     SECTION    "LaunchTask",CODE
  17.  
  18. _LaunchTask:
  19.     MOVEM.L    D0-D7/A0-A6,-(SP)    ;SP = Save registers.
  20.     move.l    a0,a5    ;a5 = Segment.
  21.     move.l    a1,a4    ;a4 = StartUp.
  22.  
  23.     ;Initialise self-destruct sequence.
  24.  
  25.     move.l    _DPKBase(pc),a6    ;a6 = DPKBase.
  26.     lea    .exit(pc),a0    ;a0 = Pointer to SelfDestruct() cleanup.
  27.     move.l    a7,a1    ;a1 = Stack pointer.
  28.     CALL    InitDestruct    ;>> = Initialise the call.
  29.  
  30.     ;Setup parameters here.  Search for
  31.     ;"PRGM" header to launch program.
  32.  
  33.     move.l    SEG_Address(a5),a0    ;a0 = Segment start.
  34.     move.l    a0,a1
  35.     lea    64(a1),a1
  36. .loop    cmp.l    a1,a0
  37.     bgt.s    .exit
  38.     cmp.w    #"PR",(a0)+
  39.     bne.s    .loop
  40.     cmp.w    #"GM",(a0)+
  41.     bne.s    .loop
  42.     subq.w    #4,a0
  43.     move.l    _DPKBase(pc),DPK_DPKBase(a0)
  44.     move.l    DPK_Start(a0),a0
  45.  
  46.     sub.l    a1,a1    ;a1 = StartUp.
  47.     sub.l    a2,a2    ;a2 = Null
  48.     sub.l    a3,a3    ;a3 = Null
  49.     sub.l    a4,a4    ;a4 = Null
  50.     sub.l    a5,a5    ;a5 = Null
  51.     move.l    _DPKBase(pc),a6    ;a6 = DPKBase
  52.  
  53.     move.l    #$00,d0    ;d0 = ID
  54.     moveq    #$00,d1    ;d1 = Null
  55.     moveq    #$00,d2    ;d2 = Null
  56.     moveq    #$00,d3    ;d3 = Null
  57.     moveq    #$00,d4    ;d4 = Null
  58.     moveq    #$00,d5    ;d5 = Null
  59.     moveq    #$00,d6    ;d6 = Null
  60.     moveq    #$00,d7    ;d7 = Null
  61.  
  62.     jsr    (a0)    ;>> = Start the DPK program.
  63.  
  64. .exit    MOVEM.L    (SP)+,D0-D7/A0-A6
  65.     rts
  66.  
  67. _DPKBase:    dc.l  0
  68.  
  69.